<template>
    <div class="container">
        <div class="row">

     


            <div class="col-md-8 col-md-offset-2" >


                <li class="list-group-item" style="border: 0px">



    <div class="form-group">
            <label  class="col-sm-2 control-label">标题</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" v-model="title" placeholder="请输入名字">
            </div>
          </div>
<br><br>
<script type="text/plain" id="editor" name="content" style="width:100%;height:300px;">
              
          </script>


          <br>
          
          <button class="btn btn-block" @click="getContent()">提交</button>
                </li>


            </div>
            

        
        </div>
    </div>
</template>

<script>

import conf from '../layout/conf.vue';//引用模块进来
    export default {
        mounted() {

     var ue = UE.getEditor('editor');  


        },
        data(){
            return {
                title:"",
                context:"",
                posturl:conf.url+"/index/post/create/",

            }
        },
        beforeCreate(){

        // var ue = UE.getEditor('editor');  
         console.log("加载咯!");

        },
        methods:{
             getContent() {
       
       let info=UE.getEditor('editor').getContent();
    
         var params = new URLSearchParams();
                params.append('title', this.title);
                params.append('content', info);
                var access_token=this.GetCookie("wlphp.cn");
                params.append('token', access_token);
                    

                    this.axios.post(this.posturl,params).then(response=>{
                        console.log(response);
                                            if(response['data']['status']=="error"){
                                                    this.message("NO","先登陆!!");
                                                    
                                                     setTimeout(function () {
                                                       location.href="/#/login";
                                                        },1000)
                                                    console.log("错误!");
                                                    console.log(response);
                                                    
                                                     

                                                }else{
                                                  this.message("ok","发布成功!");
                                                     setTimeout(function () {
                                                       location.href="/";
                                                        },1000)
                                                            
                                                }
                                               
                     

                      })
            }



        }


    }
</script>


